mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-10-26 18:39:46 -05:00
Enable tracking variable usage
This commit is contained in:
@@ -546,10 +546,8 @@ bool MacroActionVariable::PerformAction()
|
||||
bool MacroActionVariable::Save(obs_data_t *obj) const
|
||||
{
|
||||
MacroAction::Save(obj);
|
||||
obs_data_set_string(obj, "variableName",
|
||||
GetWeakVariableName(_variable).c_str());
|
||||
obs_data_set_string(obj, "variable2Name",
|
||||
GetWeakVariableName(_variable2).c_str());
|
||||
_variable.Save(obj, "variableName");
|
||||
_variable2.Save(obj, "variable2Name");
|
||||
_strValue.Save(obj, "strValue");
|
||||
_numValue.Save(obj, "numValue");
|
||||
obs_data_set_int(obj, "condition", static_cast<int>(_action));
|
||||
@@ -595,10 +593,8 @@ bool MacroActionVariable::Save(obs_data_t *obj) const
|
||||
bool MacroActionVariable::Load(obs_data_t *obj)
|
||||
{
|
||||
MacroAction::Load(obj);
|
||||
_variable =
|
||||
GetWeakVariableByName(obs_data_get_string(obj, "variableName"));
|
||||
_variable2 = GetWeakVariableByName(
|
||||
obs_data_get_string(obj, "variable2Name"));
|
||||
_variable.Load(obj, "variableName");
|
||||
_variable2.Load(obj, "variable2Name");
|
||||
_strValue.Load(obj, "strValue");
|
||||
_action = static_cast<Action>(obs_data_get_int(obj, "condition"));
|
||||
_segmentIdxLoadValue = obs_data_get_int(obj, "segmentIdx");
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "string-list.hpp"
|
||||
#include "value-input.hpp"
|
||||
#include "variable-line-edit.hpp"
|
||||
#include "variable-ref.hpp"
|
||||
#include "variable-text-edit.hpp"
|
||||
#include "variable-spinbox.hpp"
|
||||
|
||||
@@ -63,8 +64,8 @@ public:
|
||||
};
|
||||
|
||||
Action _action = Action::SET_VALUE;
|
||||
std::weak_ptr<Variable> _variable;
|
||||
std::weak_ptr<Variable> _variable2;
|
||||
VariableRef _variable;
|
||||
VariableRef _variable2;
|
||||
StringVariable _strValue = "";
|
||||
DoubleVariable _numValue = 0;
|
||||
IntVariable _subStringStart = 0;
|
||||
|
||||
@@ -164,8 +164,7 @@ bool MacroConditionTempVar::Save(obs_data_t *obj) const
|
||||
{
|
||||
MacroCondition::Save(obj);
|
||||
_tempVar.Save(obj, GetMacro());
|
||||
obs_data_set_string(obj, "variableName",
|
||||
GetWeakVariableName(_variable2).c_str());
|
||||
_variable2.Save(obj, "variableName");
|
||||
_strValue.Save(obj, "strValue");
|
||||
obs_data_set_double(obj, "numValue", _numValue);
|
||||
obs_data_set_int(obj, "condition", static_cast<int>(_type));
|
||||
@@ -177,8 +176,7 @@ bool MacroConditionTempVar::Load(obs_data_t *obj)
|
||||
{
|
||||
MacroCondition::Load(obj);
|
||||
_tempVar.Load(obj, GetMacro());
|
||||
_variable2 =
|
||||
GetWeakVariableByName(obs_data_get_string(obj, "variableName"));
|
||||
_variable2.Load(obj, "variableName");
|
||||
_strValue.Load(obj, "strValue");
|
||||
_numValue = obs_data_get_double(obj, "numValue");
|
||||
_type = static_cast<Condition>(obs_data_get_int(obj, "condition"));
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
#include "macro-condition-edit.hpp"
|
||||
#include "resizing-text-edit.hpp"
|
||||
#include "variable-ref.hpp"
|
||||
#include "variable.hpp"
|
||||
#include "regex-config.hpp"
|
||||
#include "variable-text-edit.hpp"
|
||||
@@ -40,7 +41,7 @@ public:
|
||||
|
||||
Condition _type = Condition::EQUALS;
|
||||
TempVariableRef _tempVar;
|
||||
std::weak_ptr<Variable> _variable2;
|
||||
VariableRef _variable2;
|
||||
StringVariable _strValue = "";
|
||||
double _numValue = 0;
|
||||
RegexConfig _regex;
|
||||
|
||||
@@ -129,10 +129,8 @@ bool MacroConditionVariable::CheckCondition()
|
||||
bool MacroConditionVariable::Save(obs_data_t *obj) const
|
||||
{
|
||||
MacroCondition::Save(obj);
|
||||
obs_data_set_string(obj, "variableName",
|
||||
GetWeakVariableName(_variable).c_str());
|
||||
obs_data_set_string(obj, "variable2Name",
|
||||
GetWeakVariableName(_variable2).c_str());
|
||||
_variable.Save(obj, "variableName");
|
||||
_variable2.Save(obj, "variable2Name");
|
||||
_strValue.Save(obj, "strValue");
|
||||
obs_data_set_double(obj, "numValue", _numValue);
|
||||
obs_data_set_int(obj, "condition", static_cast<int>(_type));
|
||||
@@ -143,10 +141,8 @@ bool MacroConditionVariable::Save(obs_data_t *obj) const
|
||||
bool MacroConditionVariable::Load(obs_data_t *obj)
|
||||
{
|
||||
MacroCondition::Load(obj);
|
||||
_variable =
|
||||
GetWeakVariableByName(obs_data_get_string(obj, "variableName"));
|
||||
_variable2 = GetWeakVariableByName(
|
||||
obs_data_get_string(obj, "variable2Name"));
|
||||
_variable.Load(obj, "variableName");
|
||||
_variable2.Load(obj, "variable2Name");
|
||||
_strValue.Load(obj, "strValue");
|
||||
_numValue = obs_data_get_double(obj, "numValue");
|
||||
_type = static_cast<Condition>(obs_data_get_int(obj, "condition"));
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
#include "macro-condition-edit.hpp"
|
||||
#include "resizing-text-edit.hpp"
|
||||
#include "variable-ref.hpp"
|
||||
#include "variable.hpp"
|
||||
#include "regex-config.hpp"
|
||||
#include "variable-text-edit.hpp"
|
||||
@@ -38,8 +39,8 @@ public:
|
||||
};
|
||||
|
||||
Condition _type = Condition::EQUALS;
|
||||
std::weak_ptr<Variable> _variable;
|
||||
std::weak_ptr<Variable> _variable2;
|
||||
VariableRef _variable;
|
||||
VariableRef _variable2;
|
||||
StringVariable _strValue = "";
|
||||
double _numValue = 0;
|
||||
RegexConfig _regex;
|
||||
|
||||
@@ -14,12 +14,10 @@ void MacroInputVariables::Save(obs_data_t *obj) const
|
||||
OBSDataArrayAutoRelease array = obs_data_array_create();
|
||||
for (auto &var : _inputVariables) {
|
||||
OBSDataAutoRelease arrayObj = obs_data_create();
|
||||
auto variable = var.lock();
|
||||
if (variable) {
|
||||
obs_data_set_string(arrayObj, "variableName",
|
||||
variable->Name().c_str());
|
||||
} else {
|
||||
if (var.expired()) {
|
||||
obs_data_set_bool(arrayObj, "invalidVariable", true);
|
||||
} else {
|
||||
var.Save(arrayObj, "variableName");
|
||||
}
|
||||
obs_data_array_push_back(array, arrayObj);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
#include "list-editor.hpp"
|
||||
#include "string-list.hpp"
|
||||
#include "variable-ref.hpp"
|
||||
#include "variable.hpp"
|
||||
|
||||
#include <QGridLayout>
|
||||
@@ -16,7 +17,7 @@ public:
|
||||
void SetValues(const StringList &values);
|
||||
|
||||
private:
|
||||
std::vector<std::weak_ptr<Variable>> _inputVariables;
|
||||
std::vector<VariableRef> _inputVariables;
|
||||
friend class MacroInputSelection;
|
||||
friend class MacroInputEdit;
|
||||
};
|
||||
|
||||
@@ -107,9 +107,7 @@ bool MacroSegment::Save(obs_data_t *obj) const
|
||||
for (const auto &mapping : _varMappings) {
|
||||
OBSDataAutoRelease item = obs_data_create();
|
||||
mapping.tempVar.Save(item, GetMacro(), "tempVar");
|
||||
obs_data_set_string(
|
||||
item, "variable",
|
||||
GetWeakVariableName(mapping.variable).c_str());
|
||||
mapping.variable.Save(item, "variable");
|
||||
obs_data_array_push_back(mappingsArray, item);
|
||||
}
|
||||
obs_data_set_array(data, "varMappings", mappingsArray);
|
||||
@@ -147,8 +145,7 @@ bool MacroSegment::Load(obs_data_t *obj)
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
OBSDataAutoRelease item = obs_data_array_item(mappingsArray, i);
|
||||
VarMapping mapping;
|
||||
mapping.variable = GetWeakVariableByName(
|
||||
obs_data_get_string(item, "variable"));
|
||||
mapping.variable.Load(item, "variable");
|
||||
_varMappings.push_back(std::move(mapping));
|
||||
_varMappings.back().tempVar.Load(item, GetMacro(), "tempVar");
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "obs-module-helper.hpp"
|
||||
#include "sync-helpers.hpp"
|
||||
#include "temp-variable.hpp"
|
||||
#include "variable-ref.hpp"
|
||||
|
||||
#include <obs-data.h>
|
||||
|
||||
@@ -26,7 +27,7 @@ class Variable;
|
||||
|
||||
struct VarMapping {
|
||||
TempVariableRef tempVar;
|
||||
std::weak_ptr<Variable> variable;
|
||||
VariableRef variable;
|
||||
};
|
||||
|
||||
class EXPORT MacroSegment : public Lockable {
|
||||
|
||||
@@ -32,15 +32,9 @@ void SceneSelection::Save(obs_data_t *obj) const
|
||||
obs_data_set_string(data, nameSaveName.data(),
|
||||
_group->name.c_str());
|
||||
break;
|
||||
case Type::VARIABLE: {
|
||||
auto var = _variable.lock();
|
||||
if (!var) {
|
||||
break;
|
||||
}
|
||||
obs_data_set_string(data, nameSaveName.data(),
|
||||
var->Name().c_str());
|
||||
case Type::VARIABLE:
|
||||
_variable.Save(data, nameSaveName.data());
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
#include "canvas-helpers.hpp"
|
||||
#include "variable-ref.hpp"
|
||||
|
||||
namespace advss {
|
||||
|
||||
@@ -32,7 +33,7 @@ private:
|
||||
OBSWeakSource _scene;
|
||||
OBSWeakCanvas _canvas = GetMainCanvas();
|
||||
SceneGroup *_group = nullptr;
|
||||
std::weak_ptr<Variable> _variable;
|
||||
VariableRef _variable;
|
||||
Type _type = Type::SCENE;
|
||||
friend class SceneSelectionWidget;
|
||||
};
|
||||
|
||||
@@ -19,15 +19,9 @@ void SourceSelection::Save(obs_data_t *obj, const char *name) const
|
||||
obs_data_set_string(data, nameSaveName.data(),
|
||||
GetWeakSourceName(_source).c_str());
|
||||
break;
|
||||
case Type::VARIABLE: {
|
||||
auto var = _variable.lock();
|
||||
if (!var) {
|
||||
break;
|
||||
}
|
||||
obs_data_set_string(data, nameSaveName.data(),
|
||||
var->Name().c_str());
|
||||
case Type::VARIABLE:
|
||||
_variable.Save(data, nameSaveName.data());
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
#include "filter-combo-box.hpp"
|
||||
#include "obs.hpp"
|
||||
#include "variable-ref.hpp"
|
||||
|
||||
namespace advss {
|
||||
|
||||
@@ -30,7 +31,7 @@ private:
|
||||
void LoadFallback(obs_data_t *obj, const char *name);
|
||||
|
||||
OBSWeakSource _source;
|
||||
std::weak_ptr<Variable> _variable;
|
||||
VariableRef _variable;
|
||||
Type _type = Type::SOURCE;
|
||||
friend class SourceSelectionWidget;
|
||||
};
|
||||
|
||||
@@ -11,9 +11,8 @@ void ColorVariable::Save(obs_data_t *obj, const char *name) const
|
||||
OBSDataAutoRelease data = obs_data_create();
|
||||
obs_data_set_int(data, "version", 1);
|
||||
obs_data_set_int(data, "type", static_cast<int>(_type));
|
||||
auto var = _variable.lock();
|
||||
if (var) {
|
||||
obs_data_set_string(data, "variable", var->Name().c_str());
|
||||
if (_type == Type::VARIABLE) {
|
||||
_variable.Save(data, "variable");
|
||||
}
|
||||
obs_data_set_int(data, "red", _value.red());
|
||||
obs_data_set_int(data, "green", _value.green());
|
||||
@@ -32,8 +31,7 @@ void ColorVariable::Load(obs_data_t *obj, const char *name)
|
||||
_type = Type::FIXED_VALUE;
|
||||
return;
|
||||
}
|
||||
auto variableName = obs_data_get_string(data, "variable");
|
||||
_variable = GetWeakVariableByName(variableName);
|
||||
_variable.Load(data, "variable");
|
||||
_type = static_cast<Type>(obs_data_get_int(data, "type"));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#include "variable-ref.hpp"
|
||||
#include "variable.hpp"
|
||||
|
||||
#include <obs-data.h>
|
||||
@@ -27,7 +28,7 @@ public:
|
||||
private:
|
||||
Type _type = Type::FIXED_VALUE;
|
||||
QColor _value = Qt::black;
|
||||
std::weak_ptr<Variable> _variable;
|
||||
VariableRef _variable;
|
||||
|
||||
friend class VariableColorButton;
|
||||
};
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#include "variable-ref.hpp"
|
||||
#include "variable.hpp"
|
||||
|
||||
namespace advss {
|
||||
@@ -27,7 +28,7 @@ public:
|
||||
private:
|
||||
Type _type = Type::FIXED_VALUE;
|
||||
T _value = {};
|
||||
std::weak_ptr<Variable> _variable;
|
||||
VariableRef _variable;
|
||||
|
||||
friend class GenericVariableSpinbox;
|
||||
friend class VariableSpinBox;
|
||||
|
||||
@@ -18,9 +18,8 @@ void NumberVariable<T>::Save(obs_data_t *obj, const char *name) const
|
||||
} else {
|
||||
assert(false);
|
||||
}
|
||||
auto var = _variable.lock();
|
||||
if (var) {
|
||||
obs_data_set_string(data, "variable", var->Name().c_str());
|
||||
if (_type == Type::VARIABLE) {
|
||||
_variable.Save(data, "variable");
|
||||
}
|
||||
obs_data_set_int(data, "type", static_cast<int>(_type));
|
||||
obs_data_set_obj(obj, name, data);
|
||||
@@ -38,8 +37,7 @@ void NumberVariable<T>::Load(obs_data_t *obj, const char *name)
|
||||
} else {
|
||||
assert(false);
|
||||
}
|
||||
auto variableName = obs_data_get_string(data, "variable");
|
||||
_variable = GetWeakVariableByName(variableName);
|
||||
_variable.Load(data, "variable");
|
||||
_type = static_cast<Type>(obs_data_get_int(data, "type"));
|
||||
obs_data_release(data);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "variable-string.hpp"
|
||||
#include "utility.hpp"
|
||||
#include "variable-ref.hpp"
|
||||
|
||||
namespace advss {
|
||||
|
||||
@@ -50,6 +51,7 @@ void StringVariable::Load(obs_data_t *obj, const char *name)
|
||||
void StringVariable::Save(obs_data_t *obj, const char *name) const
|
||||
{
|
||||
obs_data_set_string(obj, name, _value.c_str());
|
||||
ReportVariableRefsInText(_value);
|
||||
}
|
||||
|
||||
void StringVariable::ResolveVariables()
|
||||
|
||||
Reference in New Issue
Block a user