mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-08-28 04:06:27 -05:00
Add support to resolve variables on action queue add
This commit is contained in:
@@ -145,6 +145,21 @@ std::string MacroActionMacro::GetShortDesc() const
|
||||
return _macro.Name();
|
||||
}
|
||||
|
||||
std::shared_ptr<MacroAction> MacroActionMacro::Create(Macro *m)
|
||||
{
|
||||
return std::make_shared<MacroActionMacro>(m);
|
||||
}
|
||||
|
||||
std::shared_ptr<MacroAction> MacroActionMacro::Copy() const
|
||||
{
|
||||
return std::make_shared<MacroActionMacro>(*this);
|
||||
}
|
||||
|
||||
void MacroActionMacro::ResolveVariablesToFixedValues()
|
||||
{
|
||||
_actionIndex.ResolveVariables();
|
||||
}
|
||||
|
||||
static inline void populateActionSelection(QComboBox *list)
|
||||
{
|
||||
for (auto entry : actionTypes) {
|
||||
|
||||
@@ -16,10 +16,9 @@ public:
|
||||
bool Load(obs_data_t *obj);
|
||||
std::string GetShortDesc() const;
|
||||
std::string GetId() const { return id; };
|
||||
static std::shared_ptr<MacroAction> Create(Macro *m)
|
||||
{
|
||||
return std::make_shared<MacroActionMacro>(m);
|
||||
}
|
||||
static std::shared_ptr<MacroAction> Create(Macro *m);
|
||||
std::shared_ptr<MacroAction> Copy() const;
|
||||
void ResolveVariablesToFixedValues();
|
||||
|
||||
enum class Action {
|
||||
PAUSE,
|
||||
|
||||
@@ -114,6 +114,16 @@ std::string MacroActionQueue::GetShortDesc() const
|
||||
return GetActionQueueName(_queue);
|
||||
}
|
||||
|
||||
std::shared_ptr<MacroAction> MacroActionQueue::Create(Macro *m)
|
||||
{
|
||||
return std::make_shared<MacroActionQueue>(m);
|
||||
}
|
||||
|
||||
std::shared_ptr<MacroAction> MacroActionQueue::Copy() const
|
||||
{
|
||||
return std::make_shared<MacroActionQueue>(*this);
|
||||
}
|
||||
|
||||
static inline void populateActionSelection(QComboBox *list)
|
||||
{
|
||||
for (const auto &[_, name] : actionTypes) {
|
||||
|
||||
@@ -16,10 +16,8 @@ public:
|
||||
bool Load(obs_data_t *obj);
|
||||
std::string GetShortDesc() const;
|
||||
std::string GetId() const { return id; };
|
||||
static std::shared_ptr<MacroAction> Create(Macro *m)
|
||||
{
|
||||
return std::make_shared<MacroActionQueue>(m);
|
||||
}
|
||||
static std::shared_ptr<MacroAction> Create(Macro *m);
|
||||
std::shared_ptr<MacroAction> Copy() const;
|
||||
|
||||
enum class Action {
|
||||
ADD_TO_QUEUE,
|
||||
|
||||
@@ -198,7 +198,8 @@ void MacroActionVariable::SetToSceneItemName(Variable *var)
|
||||
|
||||
struct AskForInputParams {
|
||||
AskForInputParams(const QString &prompt_, const QString &placeholder_)
|
||||
: prompt(prompt_), placeholder(placeholder_){};
|
||||
: prompt(prompt_),
|
||||
placeholder(placeholder_){};
|
||||
QString prompt;
|
||||
QString placeholder;
|
||||
std::optional<std::string> result;
|
||||
@@ -422,6 +423,16 @@ std::string MacroActionVariable::GetShortDesc() const
|
||||
return GetWeakVariableName(_variable);
|
||||
}
|
||||
|
||||
std::shared_ptr<MacroAction> MacroActionVariable::Create(Macro *m)
|
||||
{
|
||||
return std::make_shared<MacroActionVariable>(m);
|
||||
}
|
||||
|
||||
std::shared_ptr<MacroAction> MacroActionVariable::Copy() const
|
||||
{
|
||||
return std::make_shared<MacroActionVariable>(*this);
|
||||
}
|
||||
|
||||
void MacroActionVariable::SetSegmentIndexValue(int value)
|
||||
{
|
||||
DecrementCurrentSegmentVariableRef();
|
||||
@@ -485,6 +496,19 @@ int MacroActionVariable::GetSegmentIndexValue() const
|
||||
return -1;
|
||||
}
|
||||
|
||||
void MacroActionVariable::ResolveVariablesToFixedValues()
|
||||
{
|
||||
_strValue.ResolveVariables();
|
||||
_findStr.ResolveVariables();
|
||||
_replaceStr.ResolveVariables();
|
||||
_mathExpression.ResolveVariables();
|
||||
_inputPrompt.ResolveVariables();
|
||||
_inputPlaceholder.ResolveVariables();
|
||||
_envVariableName.ResolveVariables();
|
||||
_scene.ResolveVariables();
|
||||
_sceneItemIndex.ResolveVariables();
|
||||
}
|
||||
|
||||
void MacroActionVariable::DecrementCurrentSegmentVariableRef()
|
||||
{
|
||||
auto segment = _macroSegment.lock();
|
||||
|
||||
@@ -20,12 +20,11 @@ public:
|
||||
bool PostLoad() override;
|
||||
std::string GetShortDesc() const;
|
||||
std::string GetId() const { return id; };
|
||||
static std::shared_ptr<MacroAction> Create(Macro *m)
|
||||
{
|
||||
return std::make_shared<MacroActionVariable>(m);
|
||||
}
|
||||
static std::shared_ptr<MacroAction> Create(Macro *m);
|
||||
std::shared_ptr<MacroAction> Copy() const;
|
||||
void SetSegmentIndexValue(int);
|
||||
int GetSegmentIndexValue() const;
|
||||
void ResolveVariablesToFixedValues();
|
||||
|
||||
enum class Type {
|
||||
SET_FIXED_VALUE,
|
||||
|
||||
@@ -38,6 +38,8 @@ bool MacroAction::Enabled() const
|
||||
return _enabled;
|
||||
}
|
||||
|
||||
void MacroAction::ResolveVariablesToFixedValues() {}
|
||||
|
||||
std::string_view MacroAction::GetDefaultID()
|
||||
{
|
||||
return "scene_switch";
|
||||
|
||||
@@ -8,10 +8,17 @@ class EXPORT MacroAction : public MacroSegment {
|
||||
public:
|
||||
MacroAction(Macro *m, bool supportsVariableValue = false);
|
||||
virtual ~MacroAction() = default;
|
||||
virtual std::shared_ptr<MacroAction> Copy() const = 0;
|
||||
|
||||
virtual bool PerformAction() = 0;
|
||||
virtual void LogAction() const;
|
||||
|
||||
virtual bool Save(obs_data_t *obj) const = 0;
|
||||
virtual bool Load(obs_data_t *obj) = 0;
|
||||
virtual void LogAction() const;
|
||||
|
||||
// Used to resolve variables before actions are added to action queues
|
||||
virtual void ResolveVariablesToFixedValues();
|
||||
|
||||
void SetEnabled(bool);
|
||||
bool Enabled() const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user