Add support to resolve variables on action queue add

This commit is contained in:
WarmUpTill 2024-03-01 23:42:12 +01:00 committed by WarmUpTill
parent f8dadd38b4
commit 03e71e9183
82 changed files with 835 additions and 248 deletions

View File

@ -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) {

View File

@ -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,

View File

@ -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) {

View File

@ -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,

View File

@ -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();

View File

@ -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,

View File

@ -38,6 +38,8 @@ bool MacroAction::Enabled() const
return _enabled;
}
void MacroAction::ResolveVariablesToFixedValues() {}
std::string_view MacroAction::GetDefaultID()
{
return "scene_switch";

View File

@ -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;

View File

@ -328,6 +328,27 @@ std::string MacroActionAudio::GetShortDesc() const
return _audioSource.ToString();
}
std::shared_ptr<MacroAction> MacroActionAudio::Create(Macro *m)
{
return std::make_shared<MacroActionAudio>(m);
}
std::shared_ptr<MacroAction> MacroActionAudio::Copy() const
{
return std::make_shared<MacroActionAudio>(*this);
}
void MacroActionAudio::ResolveVariablesToFixedValues()
{
_audioSource.ResolveVariables();
_syncOffset.ResolveVariables();
_balance.ResolveVariables();
_volume.ResolveVariables();
_volumeDB.ResolveVariables();
_duration.ResolveVariables();
_rate.ResolveVariables();
}
static inline void populateActionSelection(QComboBox *list)
{
for (const auto &[action, name] : actionTypes) {

View File

@ -20,10 +20,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<MacroActionAudio>(m);
}
static std::shared_ptr<MacroAction> Create(Macro *m);
std::shared_ptr<MacroAction> Copy() const;
void ResolveVariablesToFixedValues();
SourceSelection _audioSource;
@ -44,15 +43,15 @@ public:
Action _action = Action::MUTE;
FadeType _fadeType = FadeType::DURATION;
NumberVariable<int> _syncOffset = 0;
IntVariable _syncOffset = 0;
obs_monitoring_type _monitorType = OBS_MONITORING_TYPE_NONE;
NumberVariable<double> _balance = 0.5;
DoubleVariable _balance = 0.5;
bool _useDb = false;
NumberVariable<int> _volume = 0;
NumberVariable<double> _volumeDB = 0.0;
IntVariable _volume = 0;
DoubleVariable _volumeDB = 0.0;
bool _fade = false;
Duration _duration;
NumberVariable<double> _rate = 100.;
DoubleVariable _rate = 100.;
bool _wait = false;
bool _abortActiveFade = false;

View File

@ -93,6 +93,16 @@ static void copyImageFromUrl(void *param)
setMimeTypeParams(params, clipboard);
}
std::shared_ptr<MacroAction> MacroActionClipboard::Create(Macro *m)
{
return std::make_shared<MacroActionClipboard>(m);
}
std::shared_ptr<MacroAction> MacroActionClipboard::Copy() const
{
return std::make_shared<MacroActionClipboard>(*this);
}
bool MacroActionClipboard::PerformAction()
{
switch (_action) {
@ -159,6 +169,12 @@ bool MacroActionClipboard::Load(obs_data_t *obj)
return true;
}
void MacroActionClipboard::ResolveVariablesToFixedValues()
{
_text.ResolveVariables();
_url.ResolveVariables();
}
static inline void populateActionSelection(QComboBox *list)
{
for (const auto &[action, name] : actionTypes) {

View File

@ -22,16 +22,16 @@ struct ClipboardImageQueueParams : ClipboardQueueParams {
class MacroActionClipboard : public MacroAction {
public:
MacroActionClipboard(Macro *m) : MacroAction(m) {}
static std::shared_ptr<MacroAction> Create(Macro *m)
{
return std::make_shared<MacroActionClipboard>(m);
}
static std::shared_ptr<MacroAction> Create(Macro *m);
std::shared_ptr<MacroAction> Copy() const;
std::string GetId() const { return id; };
bool PerformAction();
bool Save(obs_data_t *obj) const;
bool Load(obs_data_t *obj);
void ResolveVariablesToFixedValues();
enum class Action {
COPY_TEXT,
COPY_IMAGE,

View File

@ -14,9 +14,11 @@ bool MacroActionFile::_registered = MacroActionFactory::Register(
{MacroActionFile::Create, MacroActionFileEdit::Create,
"AdvSceneSwitcher.action.file"});
const static std::map<FileAction, std::string> actionTypes = {
{FileAction::WRITE, "AdvSceneSwitcher.action.file.type.write"},
{FileAction::APPEND, "AdvSceneSwitcher.action.file.type.append"},
static const std::map<MacroActionFile::Action, std::string> actionTypes = {
{MacroActionFile::Action::WRITE,
"AdvSceneSwitcher.action.file.type.write"},
{MacroActionFile::Action::APPEND,
"AdvSceneSwitcher.action.file.type.append"},
};
bool MacroActionFile::PerformAction()
@ -25,10 +27,10 @@ bool MacroActionFile::PerformAction()
QFile file(path);
bool open = false;
switch (_action) {
case FileAction::WRITE:
case Action::WRITE:
open = file.open(QIODevice::WriteOnly);
break;
case FileAction::APPEND:
case Action::APPEND:
open = file.open(QIODevice::WriteOnly | QIODevice::Append);
break;
default:
@ -67,7 +69,7 @@ bool MacroActionFile::Load(obs_data_t *obj)
MacroAction::Load(obj);
_file.Load(obj, "file");
_text.Load(obj, "text");
_action = static_cast<FileAction>(obs_data_get_int(obj, "action"));
_action = static_cast<Action>(obs_data_get_int(obj, "action"));
return true;
}
@ -76,21 +78,36 @@ std::string MacroActionFile::GetShortDesc() const
return _file.UnresolvedValue();
}
std::shared_ptr<MacroAction> MacroActionFile::Create(Macro *m)
{
return std::make_shared<MacroActionFile>(m);
}
std::shared_ptr<MacroAction> MacroActionFile::Copy() const
{
return std::make_shared<MacroActionFile>(*this);
}
void MacroActionFile::ResolveVariablesToFixedValues()
{
_file.ResolveVariables();
_text.ResolveVariables();
}
static inline void populateActionSelection(QComboBox *list)
{
for (auto entry : actionTypes) {
list->addItem(obs_module_text(entry.second.c_str()));
for (const auto &[_, name] : actionTypes) {
list->addItem(obs_module_text(name.c_str()));
}
}
MacroActionFileEdit::MacroActionFileEdit(
QWidget *parent, std::shared_ptr<MacroActionFile> entryData)
: QWidget(parent)
: QWidget(parent),
_filePath(new FileSelection(FileSelection::Type::WRITE)),
_text(new VariableTextEdit(this)),
_actions(new QComboBox())
{
_filePath = new FileSelection(FileSelection::Type::WRITE);
_text = new VariableTextEdit(this);
_actions = new QComboBox();
populateActionSelection(_actions);
QWidget::connect(_actions, SIGNAL(currentIndexChanged(int)), this,
@ -166,7 +183,7 @@ void MacroActionFileEdit::ActionChanged(int value)
}
auto lock = LockContext();
_entryData->_action = static_cast<FileAction>(value);
_entryData->_action = static_cast<MacroActionFile::Action>(value);
}
} // namespace advss

View File

@ -7,11 +7,6 @@
namespace advss {
enum class FileAction {
WRITE,
APPEND,
};
class MacroActionFile : public MacroAction {
public:
MacroActionFile(Macro *m) : MacroAction(m) {}
@ -21,14 +16,18 @@ 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<MacroActionFile>(m);
}
static std::shared_ptr<MacroAction> Create(Macro *m);
std::shared_ptr<MacroAction> Copy() const;
void ResolveVariablesToFixedValues();
StringVariable _file = obs_module_text("AdvSceneSwitcher.enterPath");
StringVariable _text = obs_module_text("AdvSceneSwitcher.enterText");
FileAction _action = FileAction::WRITE;
enum class Action {
WRITE,
APPEND,
};
Action _action = Action::WRITE;
private:
static bool _registered;
@ -58,13 +57,12 @@ private slots:
signals:
void HeaderInfoChanged(const QString &);
protected:
private:
FileSelection *_filePath;
VariableTextEdit *_text;
QComboBox *_actions;
std::shared_ptr<MacroActionFile> _entryData;
private:
std::shared_ptr<MacroActionFile> _entryData;
bool _loading = true;
};

View File

@ -158,6 +158,24 @@ std::string MacroActionFilter::GetShortDesc() const
return "";
}
std::shared_ptr<MacroAction> MacroActionFilter::Create(Macro *m)
{
return std::make_shared<MacroActionFilter>(m);
}
std::shared_ptr<MacroAction> MacroActionFilter::Copy() const
{
return std::make_shared<MacroActionFilter>(*this);
}
void MacroActionFilter::ResolveVariablesToFixedValues()
{
_source.ResolveVariables();
_filter.ResolveVariables();
_settingsString.ResolveVariables();
_manualSettingValue.ResolveVariables();
}
static inline void populateActionSelection(QComboBox *list)
{
for (auto entry : actionTypes) {

View File

@ -20,10 +20,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<MacroActionFilter>(m);
}
static std::shared_ptr<MacroAction> Create(Macro *m);
std::shared_ptr<MacroAction> Copy() const;
void ResolveVariablesToFixedValues();
enum class Action {
ENABLE,

View File

@ -425,6 +425,16 @@ bool MacroActionHotkey::Load(obs_data_t *obj)
return true;
}
std::shared_ptr<MacroAction> MacroActionHotkey::Create(Macro *m)
{
return std::make_shared<MacroActionHotkey>(m);
}
std::shared_ptr<MacroAction> MacroActionHotkey::Copy() const
{
return std::make_shared<MacroActionHotkey>(*this);
}
static inline void populateKeySelection(QComboBox *list)
{
list->addItems({"No key",

View File

@ -18,10 +18,8 @@ public:
bool Save(obs_data_t *obj) const;
bool Load(obs_data_t *obj);
std::string GetId() const { return id; };
static std::shared_ptr<MacroAction> Create(Macro *m)
{
return std::make_shared<MacroActionHotkey>(m);
}
static std::shared_ptr<MacroAction> Create(Macro *m);
std::shared_ptr<MacroAction> Copy() const;
enum class Action {
OBS_HOTKEY,

View File

@ -133,6 +133,24 @@ std::string MacroActionHttp::GetShortDesc() const
return _url.UnresolvedValue();
}
std::shared_ptr<MacroAction> MacroActionHttp::Create(Macro *m)
{
return std::make_shared<MacroActionHttp>(m);
}
std::shared_ptr<MacroAction> MacroActionHttp::Copy() const
{
return std::make_shared<MacroActionHttp>(*this);
}
void MacroActionHttp::ResolveVariablesToFixedValues()
{
_url.ResolveVariables();
_data.ResolveVariables();
_headers.ResolveVariables();
_timeout.ResolveVariables();
}
static inline void populateMethodSelection(QComboBox *list)
{
for (auto entry : methods) {

View File

@ -20,10 +20,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<MacroActionHttp>(m);
}
static std::shared_ptr<MacroAction> Create(Macro *m);
std::shared_ptr<MacroAction> Copy() const;
void ResolveVariablesToFixedValues();
enum class Method {
GET = 0,

View File

@ -38,6 +38,16 @@ static const std::map<MacroActionMedia::SelectionType, std::string>
"AdvSceneSwitcher.action.media.selectionType.sceneItem"},
};
std::shared_ptr<MacroAction> MacroActionMedia::Create(Macro *m)
{
return std::make_shared<MacroActionMedia>(m);
}
std::shared_ptr<MacroAction> MacroActionMedia::Copy() const
{
return std::make_shared<MacroActionMedia>(*this);
}
std::string MacroActionMedia::GetShortDesc() const
{
if (_selection == SelectionType::SOURCE) {
@ -150,6 +160,15 @@ bool MacroActionMedia::Load(obs_data_t *obj)
return true;
}
void MacroActionMedia::ResolveVariablesToFixedValues()
{
_seekDuration.ResolveVariables();
_seekPercentage.ResolveVariables();
_mediaSource.ResolveVariables();
_sceneItem.ResolveVariables();
_scene.ResolveVariables();
}
static inline void populateActionSelection(QComboBox *list)
{
for (const auto &[_, name] : actionTypes) {

View File

@ -11,10 +11,8 @@ namespace advss {
class MacroActionMedia : public MacroAction {
public:
MacroActionMedia(Macro *m) : MacroAction(m) {}
static std::shared_ptr<MacroAction> Create(Macro *m)
{
return std::make_shared<MacroActionMedia>(m);
}
static std::shared_ptr<MacroAction> Create(Macro *m);
std::shared_ptr<MacroAction> Copy() const;
std::string GetId() const { return id; };
std::string GetShortDesc() const;
@ -22,6 +20,7 @@ public:
void LogAction() const;
bool Save(obs_data_t *obj) const;
bool Load(obs_data_t *obj);
void ResolveVariablesToFixedValues();
enum class Action {
PLAY,

View File

@ -1,5 +1,6 @@
#include "macro-action-osc.hpp"
#include <obs.hpp>
#include <QGroupBox>
#include <system_error>
@ -172,6 +173,21 @@ bool MacroActionOSC::Load(obs_data_t *obj)
return true;
}
std::shared_ptr<MacroAction> MacroActionOSC::Create(Macro *m)
{
return std::make_shared<MacroActionOSC>(m);
}
std::shared_ptr<MacroAction> MacroActionOSC::Copy() const
{
auto result = Create(GetMacro());
OBSDataAutoRelease data = obs_data_create();
Save(data);
result->Load(data);
result->PostLoad();
return result;
}
void MacroActionOSC::SetProtocol(Protocol p)
{
_protocol = p;
@ -190,6 +206,13 @@ void MacroActionOSC::SetPortNr(IntVariable port)
_reconnect = true;
}
void MacroActionOSC::ResolveVariablesToFixedValues()
{
_ip.ResolveVariables();
_port.ResolveVariables();
_message.ResolveVariables();
}
static void populateProtocolSelection(QComboBox *list)
{
list->addItem("TCP");

View File

@ -15,10 +15,8 @@ public:
bool Save(obs_data_t *obj) const;
bool Load(obs_data_t *obj);
std::string GetId() const { return id; };
static std::shared_ptr<MacroAction> Create(Macro *m)
{
return std::make_shared<MacroActionOSC>(m);
}
static std::shared_ptr<MacroAction> Create(Macro *m);
std::shared_ptr<MacroAction> Copy() const;
enum class Protocol {
TCP,
@ -31,6 +29,7 @@ public:
StringVariable GetIP() const { return _ip; }
void SetPortNr(IntVariable);
IntVariable GetPortNr() { return _port; }
void ResolveVariablesToFixedValues();
OSCMessage _message;

View File

@ -212,10 +212,25 @@ bool MacroActionPluginState::Load(obs_data_t *obj)
return true;
}
std::shared_ptr<MacroAction> MacroActionPluginState::Create(Macro *m)
{
return std::make_shared<MacroActionPluginState>(m);
}
std::shared_ptr<MacroAction> MacroActionPluginState::Copy() const
{
return std::make_shared<MacroActionPluginState>(*this);
}
void MacroActionPluginState::ResolveVariablesToFixedValues()
{
_settingsPath = std::string(_settingsPath);
}
static inline void populateActionSelection(QComboBox *list)
{
for (auto entry : actionTypes) {
list->addItem(obs_module_text(entry.second.c_str()));
for (const auto &[_, name] : actionTypes) {
list->addItem(obs_module_text(name.c_str()));
}
}
@ -223,8 +238,8 @@ static inline void populateValueSelection(QComboBox *list,
PluginStateAction action)
{
if (action == PluginStateAction::NO_MATCH_BEHAVIOUR) {
for (auto entry : noMatchValues) {
list->addItem(obs_module_text(entry.second.c_str()));
for (const auto &[_, name] : noMatchValues) {
list->addItem(obs_module_text(name.c_str()));
}
}
}

View File

@ -23,10 +23,9 @@ public:
bool Save(obs_data_t *obj) const;
bool Load(obs_data_t *obj);
std::string GetId() const { return id; };
static std::shared_ptr<MacroAction> Create(Macro *m)
{
return std::make_shared<MacroActionPluginState>(m);
}
static std::shared_ptr<MacroAction> Create(Macro *m);
std::shared_ptr<MacroAction> Copy() const;
void ResolveVariablesToFixedValues();
PluginStateAction _action = PluginStateAction::STOP;
int _value = 0;

View File

@ -43,6 +43,16 @@ std::string MacroActionProfile::GetShortDesc() const
return _profile;
}
std::shared_ptr<MacroAction> MacroActionProfile::Create(Macro *m)
{
return std::make_shared<MacroActionProfile>(m);
}
std::shared_ptr<MacroAction> MacroActionProfile::Copy() const
{
return std::make_shared<MacroActionProfile>(*this);
}
MacroActionProfileEdit::MacroActionProfileEdit(
QWidget *parent, std::shared_ptr<MacroActionProfile> entryData)
: QWidget(parent)

View File

@ -14,10 +14,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<MacroActionProfile>(m);
}
static std::shared_ptr<MacroAction> Create(Macro *m);
std::shared_ptr<MacroAction> Copy() const;
std::string _profile;

View File

@ -119,6 +119,22 @@ bool MacroActionProjector::Load(obs_data_t *obj)
return true;
}
std::shared_ptr<MacroAction> MacroActionProjector::Create(Macro *m)
{
return std::make_shared<MacroActionProjector>(m);
}
std::shared_ptr<MacroAction> MacroActionProjector::Copy() const
{
return std::make_shared<MacroActionProjector>(*this);
}
void MacroActionProjector::ResolveVariablesToFixedValues()
{
_source.ResolveVariables();
_scene.ResolveVariables();
}
void MacroActionProjector::SetMonitor(int idx)
{
_monitor = idx;

View File

@ -13,10 +13,9 @@ public:
bool Save(obs_data_t *obj) const;
bool Load(obs_data_t *obj);
std::string GetId() const { return id; };
static std::shared_ptr<MacroAction> Create(Macro *m)
{
return std::make_shared<MacroActionProjector>(m);
}
static std::shared_ptr<MacroAction> Create(Macro *m);
std::shared_ptr<MacroAction> Copy() const;
void ResolveVariablesToFixedValues();
void SetMonitor(int);
int GetMonitor() const;

View File

@ -83,6 +83,16 @@ bool MacroActionRandom::Load(obs_data_t *obj)
return true;
}
std::shared_ptr<MacroAction> MacroActionRandom::Create(Macro *m)
{
return std::make_shared<MacroActionRandom>(m);
}
std::shared_ptr<MacroAction> MacroActionRandom::Copy() const
{
return std::make_shared<MacroActionRandom>(*this);
}
MacroActionRandomEdit::MacroActionRandomEdit(
QWidget *parent, std::shared_ptr<MacroActionRandom> entryData)
: QWidget(parent),

View File

@ -16,10 +16,8 @@ public:
bool Save(obs_data_t *obj) const;
bool Load(obs_data_t *obj);
std::string GetId() const { return id; };
static std::shared_ptr<MacroAction> Create(Macro *m)
{
return std::make_shared<MacroActionRandom>(m);
}
static std::shared_ptr<MacroAction> Create(Macro *m);
std::shared_ptr<MacroAction> Copy() const;
bool _allowRepeat = false;

View File

@ -122,10 +122,26 @@ bool MacroActionRecord::Load(obs_data_t *obj)
return true;
}
std::shared_ptr<MacroAction> MacroActionRecord::Create(Macro *m)
{
return std::make_shared<MacroActionRecord>(m);
}
std::shared_ptr<MacroAction> MacroActionRecord::Copy() const
{
return std::make_shared<MacroActionRecord>(*this);
}
void MacroActionRecord::ResolveVariablesToFixedValues()
{
_folder.ResolveVariables();
_fileFormat.ResolveVariables();
}
static inline void populateActionSelection(QComboBox *list)
{
for (auto entry : actionTypes) {
list->addItem(obs_module_text(entry.second.c_str()));
for (const auto &[_, name] : actionTypes) {
list->addItem(obs_module_text(name.c_str()));
}
}

View File

@ -17,10 +17,9 @@ public:
bool Save(obs_data_t *obj) const;
bool Load(obs_data_t *obj);
std::string GetId() const { return id; };
static std::shared_ptr<MacroAction> Create(Macro *m)
{
return std::make_shared<MacroActionRecord>(m);
}
static std::shared_ptr<MacroAction> Create(Macro *m);
std::shared_ptr<MacroAction> Copy() const;
void ResolveVariablesToFixedValues();
enum class Action {
STOP,

View File

@ -69,10 +69,20 @@ bool MacroActionReplayBuffer::Load(obs_data_t *obj)
return true;
}
std::shared_ptr<MacroAction> MacroActionReplayBuffer::Create(Macro *m)
{
return std::make_shared<MacroActionReplayBuffer>(m);
}
std::shared_ptr<MacroAction> MacroActionReplayBuffer::Copy() const
{
return std::make_shared<MacroActionReplayBuffer>(*this);
}
static inline void populateActionSelection(QComboBox *list)
{
for (auto entry : actionTypes) {
list->addItem(obs_module_text(entry.second.c_str()));
for (const auto &[_, name] : actionTypes) {
list->addItem(obs_module_text(name.c_str()));
}
}

View File

@ -20,10 +20,8 @@ public:
bool Save(obs_data_t *obj) const;
bool Load(obs_data_t *obj);
std::string GetId() const { return id; };
static std::shared_ptr<MacroAction> Create(Macro *m)
{
return std::make_shared<MacroActionReplayBuffer>(m);
}
static std::shared_ptr<MacroAction> Create(Macro *m);
std::shared_ptr<MacroAction> Copy() const;
ReplayBufferAction _action = ReplayBufferAction::STOP;

View File

@ -64,6 +64,22 @@ std::string MacroActionRun::GetShortDesc() const
return _procConfig.UnresolvedPath();
}
std::shared_ptr<MacroAction> MacroActionRun::Create(Macro *m)
{
return std::make_shared<MacroActionRun>(m);
}
std::shared_ptr<MacroAction> MacroActionRun::Copy() const
{
return std::make_shared<MacroActionRun>(*this);
}
void MacroActionRun::ResolveVariablesToFixedValues()
{
_procConfig.ResolveVariables();
_timeout.ResolveVariables();
}
MacroActionRunEdit::MacroActionRunEdit(
QWidget *parent, std::shared_ptr<MacroActionRun> entryData)
: QWidget(parent),

View File

@ -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<MacroActionRun>(m);
}
static std::shared_ptr<MacroAction> Create(Macro *m);
std::shared_ptr<MacroAction> Copy() const;
void ResolveVariablesToFixedValues();
ProcessConfig _procConfig;
bool _wait = false;

View File

@ -54,6 +54,16 @@ std::string MacroActionSceneCollection::GetShortDesc() const
return _sceneCollection;
}
std::shared_ptr<MacroAction> MacroActionSceneCollection::Create(Macro *m)
{
return std::make_shared<MacroActionSceneCollection>(m);
}
std::shared_ptr<MacroAction> MacroActionSceneCollection::Copy() const
{
return std::make_shared<MacroActionSceneCollection>(*this);
}
void populateSceneCollectionSelection(QComboBox *box)
{
auto sceneCollections = obs_frontend_get_scene_collections();

View File

@ -14,10 +14,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<MacroActionSceneCollection>(m);
}
static std::shared_ptr<MacroAction> Create(Macro *m);
std::shared_ptr<MacroAction> Copy() const;
std::string _sceneCollection;

View File

@ -37,7 +37,6 @@ static void setSceneItemLock(obs_sceneitem_t *item,
bool MacroActionSceneLock::PerformAction()
{
auto items = _source.GetSceneItems(_scene);
for (const auto &item : items) {
setSceneItemLock(item, _action);
@ -87,6 +86,16 @@ std::string MacroActionSceneLock::GetShortDesc() const
return "";
}
std::shared_ptr<MacroAction> MacroActionSceneLock::Create(Macro *m)
{
return std::make_shared<MacroActionSceneLock>(m);
}
std::shared_ptr<MacroAction> MacroActionSceneLock::Copy() const
{
return std::make_shared<MacroActionSceneLock>(*this);
}
static inline void populateActionSelection(QComboBox *list)
{
for (const auto &[_, name] : actionTypes) {
@ -94,6 +103,12 @@ static inline void populateActionSelection(QComboBox *list)
}
}
void MacroActionSceneLock::ResolveVariablesToFixedValues()
{
_scene.ResolveVariables();
_source.ResolveVariables();
}
MacroActionSceneLockEdit::MacroActionSceneLockEdit(
QWidget *parent, std::shared_ptr<MacroActionSceneLock> entryData)
: QWidget(parent),

View File

@ -14,10 +14,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<MacroActionSceneLock>(m);
}
static std::shared_ptr<MacroAction> Create(Macro *m);
std::shared_ptr<MacroAction> Copy() const;
void ResolveVariablesToFixedValues();
enum class Action {
LOCK,

View File

@ -142,6 +142,22 @@ std::string MacroActionSceneOrder::GetShortDesc() const
return _scene.ToString() + " - " + _source.ToString();
}
std::shared_ptr<MacroAction> MacroActionSceneOrder::Create(Macro *m)
{
return std::make_shared<MacroActionSceneOrder>(m);
}
std::shared_ptr<MacroAction> MacroActionSceneOrder::Copy() const
{
return std::make_shared<MacroActionSceneOrder>(*this);
}
void MacroActionSceneOrder::ResolveVariablesToFixedValues()
{
_scene.ResolveVariables();
_source.ResolveVariables();
}
static inline void populateActionSelection(QComboBox *list)
{
for (const auto &entry : actionTypes) {

View File

@ -24,10 +24,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<MacroActionSceneOrder>(m);
}
static std::shared_ptr<MacroAction> Create(Macro *m);
std::shared_ptr<MacroAction> Copy() const;
void ResolveVariablesToFixedValues();
SceneSelection _scene;
SceneItemSelection _source;

View File

@ -198,6 +198,22 @@ std::string MacroActionSwitchScene::GetShortDesc() const
return _scene.ToString();
}
std::shared_ptr<MacroAction> MacroActionSwitchScene::Create(Macro *m)
{
return std::make_shared<MacroActionSwitchScene>(m);
}
std::shared_ptr<MacroAction> MacroActionSwitchScene::Copy() const
{
return std::make_shared<MacroActionSwitchScene>(*this);
}
void MacroActionSwitchScene::ResolveVariablesToFixedValues()
{
_scene.ResolveVariables();
_duration.ResolveVariables();
}
static inline void populateTypeSelection(QComboBox *list)
{
for (const auto &[_, name] : sceneTypes) {

View File

@ -17,11 +17,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<MacroActionSwitchScene>(m);
}
static std::shared_ptr<MacroAction> Create(Macro *m);
std::shared_ptr<MacroAction> Copy() const;
void ResolveVariablesToFixedValues();
enum class SceneType { PROGRAM, PREVIEW };
SceneType _sceneType = SceneType::PROGRAM;

View File

@ -312,6 +312,24 @@ std::string MacroActionSceneTransform::GetShortDesc() const
return _scene.ToString() + " - " + _source.ToString();
}
std::shared_ptr<MacroAction> MacroActionSceneTransform::Create(Macro *m)
{
return std::make_shared<MacroActionSceneTransform>(m);
}
std::shared_ptr<MacroAction> MacroActionSceneTransform::Copy() const
{
return std::make_shared<MacroActionSceneTransform>(*this);
}
void MacroActionSceneTransform::ResolveVariablesToFixedValues()
{
_scene.ResolveVariables();
_source.ResolveVariables();
_settings.ResolveVariables();
_rotation.ResolveVariables();
}
std::string MacroActionSceneTransform::ConvertSettings()
{
auto data = obs_data_create();

View File

@ -18,10 +18,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<MacroActionSceneTransform>(m);
}
static std::shared_ptr<MacroAction> Create(Macro *m);
std::shared_ptr<MacroAction> Copy() const;
void ResolveVariablesToFixedValues();
enum class Action {
RESET,

View File

@ -101,6 +101,22 @@ std::string MacroActionSceneVisibility::GetShortDesc() const
return "";
}
std::shared_ptr<MacroAction> MacroActionSceneVisibility::Create(Macro *m)
{
return std::make_shared<MacroActionSceneVisibility>(m);
}
std::shared_ptr<MacroAction> MacroActionSceneVisibility::Copy() const
{
return std::make_shared<MacroActionSceneVisibility>(*this);
}
void MacroActionSceneVisibility::ResolveVariablesToFixedValues()
{
_scene.ResolveVariables();
_source.ResolveVariables();
}
static inline void populateActionSelection(QComboBox *list)
{
for (const auto &entry : actionTypes) {

View File

@ -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<MacroActionSceneVisibility>(m);
}
static std::shared_ptr<MacroAction> Create(Macro *m);
std::shared_ptr<MacroAction> Copy() const;
void ResolveVariablesToFixedValues();
SceneSelection _scene;
SceneItemSelection _source;

View File

@ -6,8 +6,6 @@
namespace advss {
const uint32_t MacroActionScreenshot::_version = 1;
const std::string MacroActionScreenshot::id = "screenshot";
bool MacroActionScreenshot::_registered = MacroActionFactory::Register(
@ -92,7 +90,7 @@ bool MacroActionScreenshot::Save(obs_data_t *obj) const
obs_data_set_int(obj, "saveType", static_cast<int>(_saveType));
obs_data_set_int(obj, "targetType", static_cast<int>(_targetType));
_path.Save(obj, "savePath");
obs_data_set_int(obj, "version", _version);
obs_data_set_int(obj, "version", 1);
return true;
}
@ -125,6 +123,28 @@ std::string MacroActionScreenshot::GetShortDesc() const
return "";
}
std::shared_ptr<MacroAction> MacroActionScreenshot::Create(Macro *m)
{
return std::make_shared<MacroActionScreenshot>(m);
}
std::shared_ptr<MacroAction> MacroActionScreenshot::Copy() const
{
auto result = Create(GetMacro());
OBSDataAutoRelease data = obs_data_create();
Save(data);
result->Load(data);
result->PostLoad();
return result;
}
void MacroActionScreenshot::ResolveVariablesToFixedValues()
{
_scene.ResolveVariables();
_source.ResolveVariables();
_path.ResolveVariables();
}
static void populateSaveTypeSelection(QComboBox *list)
{
list->addItem(obs_module_text(

View File

@ -18,15 +18,16 @@ 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<MacroActionScreenshot>(m);
}
static std::shared_ptr<MacroAction> Create(Macro *m);
std::shared_ptr<MacroAction> Copy() const;
void ResolveVariablesToFixedValues();
enum class SaveType {
OBS_DEFAULT,
CUSTOM,
};
SaveType _saveType = SaveType::OBS_DEFAULT;
enum class TargetType {
SOURCE,
SCENE,
@ -43,7 +44,6 @@ private:
ScreenshotHelper _screenshot;
const static uint32_t _version;
static bool _registered;
static const std::string id;
};

View File

@ -66,6 +66,21 @@ MacroRef MacroActionSequence::GetNextMacro(bool advance)
return res;
}
std::shared_ptr<MacroAction> MacroActionSequence::Create(Macro *m)
{
return std::make_shared<MacroActionSequence>(m);
}
std::shared_ptr<MacroAction> MacroActionSequence::Copy() const
{
return std::make_shared<MacroActionSequence>(*this);
}
void MacroActionSequence::ResolveVariablesToFixedValues()
{
_resetIndex.ResolveVariables();
}
bool MacroActionSequence::RunSequence()
{
if (_macros.size() == 0) {

View File

@ -14,7 +14,9 @@ namespace advss {
class MacroActionSequence : public MultiMacroRefAction, public MacroRefAction {
public:
MacroActionSequence(Macro *m)
: MacroAction(m), MultiMacroRefAction(m), MacroRefAction(m)
: MacroAction(m),
MultiMacroRefAction(m),
MacroRefAction(m)
{
}
bool PerformAction();
@ -24,10 +26,9 @@ public:
bool PostLoad() override;
std::string GetId() const { return id; };
MacroRef GetNextMacro(bool advance = true);
static std::shared_ptr<MacroAction> Create(Macro *m)
{
return std::make_shared<MacroActionSequence>(m);
}
static std::shared_ptr<MacroAction> Create(Macro *m);
std::shared_ptr<MacroAction> Copy() const;
void ResolveVariablesToFixedValues();
enum class Action {
RUN_SEQUENCE,

View File

@ -266,6 +266,23 @@ std::string MacroActionSource::GetShortDesc() const
return "";
}
std::shared_ptr<MacroAction> MacroActionSource::Create(Macro *m)
{
return std::make_shared<MacroActionSource>(m);
}
std::shared_ptr<MacroAction> MacroActionSource::Copy() const
{
return std::make_shared<MacroActionSource>(*this);
}
void MacroActionSource::ResolveVariablesToFixedValues()
{
_source.ResolveVariables();
_settingsString.ResolveVariables();
_manualSettingValue.ResolveVariables();
}
static inline void populateActionSelection(QComboBox *list)
{
for (auto &[actionType, name] : actionTypes) {

View File

@ -29,10 +29,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<MacroActionSource>(m);
}
static std::shared_ptr<MacroAction> Create(Macro *m);
std::shared_ptr<MacroAction> Copy() const;
void ResolveVariablesToFixedValues();
SourceSelection _source;
SourceSettingButton _button;

View File

@ -153,6 +153,22 @@ bool MacroActionStream::Load(obs_data_t *obj)
return true;
}
std::shared_ptr<MacroAction> MacroActionStream::Create(Macro *m)
{
return std::make_shared<MacroActionStream>(m);
}
std::shared_ptr<MacroAction> MacroActionStream::Copy() const
{
return std::make_shared<MacroActionStream>(*this);
}
void MacroActionStream::ResolveVariablesToFixedValues()
{
_keyFrameInterval.ResolveVariables();
_stringValue.ResolveVariables();
}
static inline void populateActionSelection(QComboBox *list)
{
for (auto entry : actionTypes) {

View File

@ -18,10 +18,9 @@ public:
bool Save(obs_data_t *obj) const;
bool Load(obs_data_t *obj);
std::string GetId() const { return id; };
static std::shared_ptr<MacroAction> Create(Macro *m)
{
return std::make_shared<MacroActionStream>(m);
}
static std::shared_ptr<MacroAction> Create(Macro *m);
std::shared_ptr<MacroAction> Copy() const;
void ResolveVariablesToFixedValues();
enum class Action {
STOP,

View File

@ -101,6 +101,21 @@ std::string MacroActionSudioMode::GetShortDesc() const
return "";
}
std::shared_ptr<MacroAction> MacroActionSudioMode::Create(Macro *m)
{
return std::make_shared<MacroActionSudioMode>(m);
}
std::shared_ptr<MacroAction> MacroActionSudioMode::Copy() const
{
return std::make_shared<MacroActionSudioMode>(*this);
}
void MacroActionSudioMode::ResolveVariablesToFixedValues()
{
_scene.ResolveVariables();
}
static inline void populateActionSelection(QComboBox *list)
{
for (const auto &[id, name] : actionTypes) {

View File

@ -13,10 +13,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<MacroActionSudioMode>(m);
}
static std::shared_ptr<MacroAction> Create(Macro *m);
std::shared_ptr<MacroAction> Copy() const;
void ResolveVariablesToFixedValues();
enum class Action {
SWAP_SCENE,

View File

@ -50,6 +50,23 @@ bool MacroActionSystray::Load(obs_data_t *obj)
return true;
}
std::shared_ptr<MacroAction> MacroActionSystray::Create(Macro *m)
{
return std::make_shared<MacroActionSystray>(m);
}
std::shared_ptr<MacroAction> MacroActionSystray::Copy() const
{
return std::make_shared<MacroActionSystray>(*this);
}
void MacroActionSystray::ResolveVariablesToFixedValues()
{
_message.ResolveVariables();
_title.ResolveVariables();
_iconPath.ResolveVariables();
}
MacroActionSystrayEdit::MacroActionSystrayEdit(
QWidget *parent, std::shared_ptr<MacroActionSystray> entryData)
: QWidget(parent),

View File

@ -15,10 +15,9 @@ public:
bool Save(obs_data_t *obj) const;
bool Load(obs_data_t *obj);
std::string GetId() const { return id; };
static std::shared_ptr<MacroAction> Create(Macro *m)
{
return std::make_shared<MacroActionSystray>(m);
}
static std::shared_ptr<MacroAction> Create(Macro *m);
std::shared_ptr<MacroAction> Copy() const;
void ResolveVariablesToFixedValues();
StringVariable _message = "";
StringVariable _title = obs_module_text("AdvSceneSwitcher.pluginName");

View File

@ -14,11 +14,14 @@ bool MacroActionTimer::_registered = MacroActionFactory::Register(
{MacroActionTimer::Create, MacroActionTimerEdit::Create,
"AdvSceneSwitcher.action.timer"});
const static std::map<TimerAction, std::string> timerActions = {
{TimerAction::PAUSE, "AdvSceneSwitcher.action.timer.type.pause"},
{TimerAction::CONTINUE, "AdvSceneSwitcher.action.timer.type.continue"},
{TimerAction::RESET, "AdvSceneSwitcher.action.timer.type.reset"},
{TimerAction::SET_TIME_REMAINING,
const static std::map<MacroActionTimer::Action, std::string> timerActions = {
{MacroActionTimer::Action::PAUSE,
"AdvSceneSwitcher.action.timer.type.pause"},
{MacroActionTimer::Action::CONTINUE,
"AdvSceneSwitcher.action.timer.type.continue"},
{MacroActionTimer::Action::RESET,
"AdvSceneSwitcher.action.timer.type.reset"},
{MacroActionTimer::Action::SET_TIME_REMAINING,
"AdvSceneSwitcher.action.timer.type.setTimeRemaining"},
};
@ -40,16 +43,16 @@ bool MacroActionTimer::PerformAction()
}
switch (_actionType) {
case TimerAction::PAUSE:
case Action::PAUSE:
timerCondition->Pause();
break;
case TimerAction::CONTINUE:
case Action::CONTINUE:
timerCondition->Continue();
break;
case TimerAction::RESET:
case Action::RESET:
timerCondition->Reset();
break;
case TimerAction::SET_TIME_REMAINING:
case Action::SET_TIME_REMAINING:
timerCondition->_duration.SetTimeRemaining(
_duration.Seconds());
break;
@ -67,19 +70,19 @@ void MacroActionTimer::LogAction() const
return;
}
switch (_actionType) {
case TimerAction::PAUSE:
case Action::PAUSE:
vblog(LOG_INFO, "paused timers on \"%s\"",
GetMacroName(macro.get()).c_str());
break;
case TimerAction::CONTINUE:
case Action::CONTINUE:
vblog(LOG_INFO, "continued timers on \"%s\"",
GetMacroName(macro.get()).c_str());
break;
case TimerAction::RESET:
case Action::RESET:
vblog(LOG_INFO, "reset timers on \"%s\"",
GetMacroName(macro.get()).c_str());
break;
case TimerAction::SET_TIME_REMAINING:
case Action::SET_TIME_REMAINING:
vblog(LOG_INFO,
"set time remaining of timers on \"%s\" to \"%s\"",
GetMacroName(macro.get()).c_str(),
@ -104,8 +107,7 @@ bool MacroActionTimer::Load(obs_data_t *obj)
MacroAction::Load(obj);
_macro.Load(obj);
_duration.Load(obj);
_actionType =
static_cast<TimerAction>(obs_data_get_int(obj, "actionType"));
_actionType = static_cast<Action>(obs_data_get_int(obj, "actionType"));
return true;
}
@ -114,10 +116,25 @@ std::string MacroActionTimer::GetShortDesc() const
return _macro.Name();
}
std::shared_ptr<MacroAction> MacroActionTimer::Create(Macro *m)
{
return std::make_shared<MacroActionTimer>(m);
}
std::shared_ptr<MacroAction> MacroActionTimer::Copy() const
{
return std::make_shared<MacroActionTimer>(*this);
}
void MacroActionTimer::ResolveVariablesToFixedValues()
{
_duration.ResolveVariables();
}
static inline void populateTypeSelection(QComboBox *list)
{
for (auto entry : timerActions) {
list->addItem(obs_module_text(entry.second.c_str()));
for (const auto &[_, name] : timerActions) {
list->addItem(obs_module_text(name.c_str()));
}
}
@ -173,7 +190,7 @@ void MacroActionTimerEdit::ActionTypeChanged(int value)
}
auto lock = LockContext();
_entryData->_actionType = static_cast<TimerAction>(value);
_entryData->_actionType = static_cast<MacroActionTimer::Action>(value);
SetWidgetVisibility();
}
@ -183,7 +200,7 @@ void MacroActionTimerEdit::SetWidgetVisibility()
return;
}
_duration->setVisible(_entryData->_actionType ==
TimerAction::SET_TIME_REMAINING);
MacroActionTimer::Action::SET_TIME_REMAINING);
adjustSize();
}

View File

@ -8,13 +8,6 @@
namespace advss {
enum class TimerAction {
PAUSE,
CONTINUE,
RESET,
SET_TIME_REMAINING,
};
class MacroActionTimer : public MacroRefAction {
public:
MacroActionTimer(Macro *m) : MacroAction(m), MacroRefAction(m) {}
@ -24,12 +17,19 @@ 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<MacroActionTimer>(m);
}
static std::shared_ptr<MacroAction> Create(Macro *m);
std::shared_ptr<MacroAction> Copy() const;
void ResolveVariablesToFixedValues();
Duration _duration;
TimerAction _actionType = TimerAction::PAUSE;
enum class Action {
PAUSE,
CONTINUE,
RESET,
SET_TIME_REMAINING,
};
Action _actionType = Action::PAUSE;
private:
static bool _registered;

View File

@ -209,10 +209,27 @@ std::string MacroActionTransition::GetShortDesc() const
return "";
}
std::shared_ptr<MacroAction> MacroActionTransition::Create(Macro *m)
{
return std::make_shared<MacroActionTransition>(m);
}
std::shared_ptr<MacroAction> MacroActionTransition::Copy() const
{
return std::make_shared<MacroActionTransition>(*this);
}
void MacroActionTransition::ResolveVariablesToFixedValues()
{
_source.ResolveVariables();
_scene.ResolveVariables();
_duration.ResolveVariables();
}
static inline void populateActionSelection(QComboBox *list)
{
for (const auto &entry : actionTypes) {
list->addItem(obs_module_text(entry.second.c_str()));
for (const auto &[_, name] : actionTypes) {
list->addItem(obs_module_text(name.c_str()));
}
}

View File

@ -19,10 +19,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<MacroActionTransition>(m);
}
static std::shared_ptr<MacroAction> Create(Macro *m);
std::shared_ptr<MacroAction> Copy() const;
void ResolveVariablesToFixedValues();
enum class Type {
SCENE,

View File

@ -12,21 +12,23 @@ bool MacroActionVCam::_registered = MacroActionFactory::Register(
{MacroActionVCam::Create, MacroActionVCamEdit::Create,
"AdvSceneSwitcher.action.virtualCamera"});
const static std::map<VCamAction, std::string> actionTypes = {
{VCamAction::STOP, "AdvSceneSwitcher.action.virtualCamera.type.stop"},
{VCamAction::START, "AdvSceneSwitcher.action.virtualCamera.type.start"},
static const std::map<MacroActionVCam::Action, std::string> actionTypes = {
{MacroActionVCam::Action::STOP,
"AdvSceneSwitcher.action.virtualCamera.type.stop"},
{MacroActionVCam::Action::START,
"AdvSceneSwitcher.action.virtualCamera.type.start"},
};
bool MacroActionVCam::PerformAction()
{
#if LIBOBS_API_VER >= MAKE_SEMANTIC_VERSION(27, 0, 0)
switch (_action) {
case VCamAction::STOP:
case Action::STOP:
if (obs_frontend_virtualcam_active()) {
obs_frontend_stop_virtualcam();
}
break;
case VCamAction::START:
case Action::START:
if (!obs_frontend_virtualcam_active()) {
obs_frontend_start_virtualcam();
}
@ -59,14 +61,24 @@ bool MacroActionVCam::Save(obs_data_t *obj) const
bool MacroActionVCam::Load(obs_data_t *obj)
{
MacroAction::Load(obj);
_action = static_cast<VCamAction>(obs_data_get_int(obj, "action"));
_action = static_cast<Action>(obs_data_get_int(obj, "action"));
return true;
}
std::shared_ptr<MacroAction> MacroActionVCam::Create(Macro *m)
{
return std::shared_ptr<MacroAction>();
}
std::shared_ptr<MacroAction> MacroActionVCam::Copy() const
{
return std::shared_ptr<MacroAction>();
}
static inline void populateActionSelection(QComboBox *list)
{
for (auto entry : actionTypes) {
list->addItem(obs_module_text(entry.second.c_str()));
for (const auto &[_, name] : actionTypes) {
list->addItem(obs_module_text(name.c_str()));
}
}
@ -110,7 +122,7 @@ void MacroActionVCamEdit::ActionChanged(int value)
}
auto lock = LockContext();
_entryData->_action = static_cast<VCamAction>(value);
_entryData->_action = static_cast<MacroActionVCam::Action>(value);
}
} // namespace advss

View File

@ -6,11 +6,6 @@
namespace advss {
enum class VCamAction {
STOP,
START,
};
class MacroActionVCam : public MacroAction {
public:
MacroActionVCam(Macro *m) : MacroAction(m) {}
@ -19,12 +14,14 @@ public:
bool Save(obs_data_t *obj) const;
bool Load(obs_data_t *obj);
std::string GetId() const { return id; };
static std::shared_ptr<MacroAction> Create(Macro *m)
{
return std::make_shared<MacroActionVCam>(m);
}
static std::shared_ptr<MacroAction> Create(Macro *m);
std::shared_ptr<MacroAction> Copy() const;
VCamAction _action = VCamAction::STOP;
enum class Action {
STOP,
START,
};
Action _action = Action::STOP;
private:
static bool _registered;

View File

@ -97,10 +97,26 @@ std::string MacroActionWait::GetShortDesc() const
return _duration.ToString() + " - " + _duration2.ToString();
}
std::shared_ptr<MacroAction> MacroActionWait::Create(Macro *m)
{
return std::make_shared<MacroActionWait>(m);
}
std::shared_ptr<MacroAction> MacroActionWait::Copy() const
{
return std::make_shared<MacroActionWait>(*this);
}
void MacroActionWait::ResolveVariablesToFixedValues()
{
_duration.ResolveVariables();
_duration2.ResolveVariables();
}
static inline void populateTypeSelection(QComboBox *list)
{
for (const auto &entry : waitTypes) {
list->addItem(obs_module_text(entry.second.c_str()));
for (const auto &[_, name] : waitTypes) {
list->addItem(obs_module_text(name.c_str()));
}
}

View File

@ -15,10 +15,10 @@ 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<MacroActionWait>(m);
}
static std::shared_ptr<MacroAction> Create(Macro *m);
std::shared_ptr<MacroAction> Copy() const;
void ResolveVariablesToFixedValues();
Duration _duration;
Duration _duration2;

View File

@ -116,6 +116,21 @@ std::string MacroActionWebsocket::GetShortDesc() const
return "";
}
std::shared_ptr<MacroAction> MacroActionWebsocket::Create(Macro *m)
{
return std::make_shared<MacroActionWebsocket>(m);
}
std::shared_ptr<MacroAction> MacroActionWebsocket::Copy() const
{
return std::make_shared<MacroActionWebsocket>(*this);
}
void MacroActionWebsocket::ResolveVariablesToFixedValues()
{
_message.ResolveVariables();
}
static inline void populateAPISelection(QComboBox *list)
{
for (const auto &[_, name] : apiTypes) {

View File

@ -19,10 +19,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<MacroActionWebsocket>(m);
}
static std::shared_ptr<MacroAction> Create(Macro *m);
std::shared_ptr<MacroAction> Copy() const;
void ResolveVariablesToFixedValues();
enum class API {
SCENE_SWITCHER,

View File

@ -136,6 +136,21 @@ std::string MacroActionWindow::GetShortDesc() const
return _window;
}
std::shared_ptr<MacroAction> MacroActionWindow::Create(Macro *m)
{
return std::make_shared<MacroActionWindow>(m);
}
std::shared_ptr<MacroAction> MacroActionWindow::Copy() const
{
return std::make_shared<MacroActionWindow>(*this);
}
void MacroActionWindow::ResolveVariablesToFixedValues()
{
_window.ResolveVariables();
}
static inline void populateActionSelection(QComboBox *list)
{
for (const auto &[_, name] : actionTypes) {

View File

@ -14,10 +14,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<MacroActionWindow>(m);
}
static std::shared_ptr<MacroAction> Create(Macro *m);
std::shared_ptr<MacroAction> Copy() const;
void ResolveVariablesToFixedValues();
enum class Action {
SET_FOCUS_WINDOW,

View File

@ -48,6 +48,21 @@ std::string MacroActionMidi::GetShortDesc() const
return _device.Name();
}
void MacroActionMidi::ResolveVariablesToFixedValues()
{
_message.ResolveVariables();
}
std::shared_ptr<MacroAction> MacroActionMidi::Create(Macro *m)
{
return std::make_shared<MacroActionMidi>(m);
}
std::shared_ptr<MacroAction> MacroActionMidi::Copy() const
{
return std::make_shared<MacroActionMidi>(*this);
}
MacroActionMidiEdit::MacroActionMidiEdit(
QWidget *parent, std::shared_ptr<MacroActionMidi> entryData)
: QWidget(parent),

View File

@ -15,11 +15,10 @@ public:
bool Save(obs_data_t *obj) const;
bool Load(obs_data_t *obj);
std::string GetShortDesc() const;
void ResolveVariablesToFixedValues();
std::string GetId() const { return id; };
static std::shared_ptr<MacroAction> Create(Macro *m)
{
return std::make_shared<MacroActionMidi>(m);
}
static std::shared_ptr<MacroAction> Create(Macro *m);
std::shared_ptr<MacroAction> Copy() const;
MidiDevice _device;
MidiMessage _message;

View File

@ -91,6 +91,13 @@ std::string MidiMessage::ToString() const
" Value: " + std::to_string(_value);
}
void MidiMessage::ResolveVariables()
{
_channel.ResolveVariables();
_note.ResolveVariables();
_value.ResolveVariables();
}
std::string MidiMessage::ToString(const libremidi::message &msg)
{
return "Type: " + GetMidiType(msg) +

View File

@ -38,6 +38,8 @@ public:
int Note() const { return _note; }
int Value() const { return _value; }
void ResolveVariables();
private:
// Values which don't appear for channel, note, and value will be used
// to indicate whether this part of the message is optional and can be

View File

@ -110,8 +110,9 @@ TwitchChannel::GetLiveInfo(const TwitchToken &token)
return {};
}
httplib::Params params = {
{"first", "1"}, {"after", ""}, {"user_id", id}};
httplib::Params params = {{"first", "1"},
{"after", ""},
{"user_id", id}};
auto result = SendGetRequest(token, "https://api.twitch.tv",
"/helix/streams", params, true);
if (result.status != 200) {
@ -151,8 +152,9 @@ std::optional<ChannelInfo> TwitchChannel::GetInfo(const TwitchToken &token)
return {};
}
httplib::Params params = {
{"first", "1"}, {"after", ""}, {"broadcaster_id", id}};
httplib::Params params = {{"first", "1"},
{"after", ""},
{"broadcaster_id", id}};
auto result = SendGetRequest(token, "https://api.twitch.tv",
"/helix/channels", params, true);
if (result.status != 200) {
@ -183,6 +185,11 @@ std::optional<ChannelInfo> TwitchChannel::GetInfo(const TwitchToken &token)
return info;
}
void TwitchChannel::ResolveVariables()
{
_name.ResolveVariables();
}
bool TwitchChannel::IsValid(const std::string &id) const
{
return id != "invalid" && !id.empty();

View File

@ -48,11 +48,12 @@ struct ChannelInfo {
struct TwitchChannel {
void Load(obs_data_t *obj);
void Save(obs_data_t *obj) const;
StringVariable GetName() const { return _name; };
StringVariable GetName() const { return _name; }
std::string GetUserID(const TwitchToken &token) const;
bool IsValid(const std::string &id) const;
std::optional<ChannelLiveInfo> GetLiveInfo(const TwitchToken &);
std::optional<ChannelInfo> GetInfo(const TwitchToken &);
void ResolveVariables();
private:
StringVariable _name = "";

View File

@ -13,6 +13,26 @@ bool MacroActionTwitch::_registered = MacroActionFactory::Register(
{MacroActionTwitch::Create, MacroActionTwitchEdit::Create,
"AdvSceneSwitcher.action.twitch"});
void MacroActionTwitch::ResolveVariablesToFixedValues()
{
_streamTitle.ResolveVariables();
_markerDescription.ResolveVariables();
_duration.ResolveVariables();
_announcementMessage.ResolveVariables();
_channel.ResolveVariables();
_chatMessage.ResolveVariables();
}
std::shared_ptr<MacroAction> MacroActionTwitch::Create(Macro *m)
{
return std::make_shared<MacroActionTwitch>(m);
}
std::shared_ptr<MacroAction> MacroActionTwitch::Copy() const
{
return std::make_shared<MacroActionTwitch>(*this);
}
std::string MacroActionTwitch::GetShortDesc() const
{
return GetWeakTwitchTokenName(_token);

View File

@ -15,10 +15,9 @@ namespace advss {
class MacroActionTwitch : public MacroAction {
public:
MacroActionTwitch(Macro *m) : MacroAction(m) {}
static std::shared_ptr<MacroAction> Create(Macro *m)
{
return std::make_shared<MacroActionTwitch>(m);
}
static std::shared_ptr<MacroAction> Create(Macro *m);
std::shared_ptr<MacroAction> Copy() const;
std::string GetId() const { return id; };
std::string GetShortDesc() const;
@ -151,6 +150,7 @@ public:
void LogAction() const;
bool Save(obs_data_t *obj) const;
bool Load(obs_data_t *obj);
void ResolveVariablesToFixedValues();
void SetAction(Action);
Action GetAction() const { return _action; }
bool ActionIsSupportedByToken();