mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-09-07 00:56:00 -05:00
Fix conditions and actions referencing macros not loading correctly
The reason is that while loading the required macro might not have been loaded resulting in the pointer to the macro never being set correctly in the loading phase.
This commit is contained in:
@@ -8,7 +8,7 @@ enum class PauseAction {
|
||||
UNPAUSE,
|
||||
};
|
||||
|
||||
class MacroActionPause : public MacroAction {
|
||||
class MacroActionPause : public MacroRefAction {
|
||||
public:
|
||||
bool PerformAction();
|
||||
void LogAction();
|
||||
@@ -21,7 +21,6 @@ public:
|
||||
}
|
||||
|
||||
PauseAction _action = PauseAction::PAUSE;
|
||||
Macro *_macro = nullptr;
|
||||
|
||||
private:
|
||||
static bool _registered;
|
||||
|
||||
@@ -12,7 +12,7 @@ enum class CounterCondition {
|
||||
EQUAL,
|
||||
};
|
||||
|
||||
class MacroConditionCounter : public MacroCondition {
|
||||
class MacroConditionCounter : public MacroRefCondition {
|
||||
public:
|
||||
bool CheckCondition();
|
||||
bool Save(obs_data_t *obj);
|
||||
@@ -23,7 +23,6 @@ public:
|
||||
return std::make_shared<MacroConditionCounter>();
|
||||
}
|
||||
|
||||
Macro *_macro = nullptr;
|
||||
CounterCondition _condition = CounterCondition::BELOW;
|
||||
int _count = 0;
|
||||
|
||||
|
||||
@@ -59,7 +59,6 @@ public:
|
||||
};
|
||||
|
||||
class Macro {
|
||||
|
||||
public:
|
||||
Macro(std::string name = "");
|
||||
virtual ~Macro();
|
||||
@@ -81,6 +80,9 @@ public:
|
||||
|
||||
bool Save(obs_data_t *obj);
|
||||
bool Load(obs_data_t *obj);
|
||||
// Some macros can refer to other macros, which are not yet loaded.
|
||||
// Use this function to set these references after loading is complete.
|
||||
void ResolveMacroRef();
|
||||
|
||||
// Helper function for plugin state condition regarding scene change
|
||||
bool SwitchesScene();
|
||||
@@ -96,3 +98,32 @@ private:
|
||||
|
||||
Macro *GetMacroByName(const char *name);
|
||||
Macro *GetMacroByQString(const QString &name);
|
||||
|
||||
class MacroRef {
|
||||
public:
|
||||
MacroRef(){};
|
||||
MacroRef(std::string name);
|
||||
void UpdateRef();
|
||||
void UpdateRef(std::string name);
|
||||
void UpdateRef(QString name);
|
||||
void Save(obs_data_t *obj);
|
||||
void Load(obs_data_t *obj);
|
||||
Macro *get();
|
||||
Macro *operator->();
|
||||
|
||||
private:
|
||||
std::string _name = "";
|
||||
Macro *_ref = nullptr;
|
||||
};
|
||||
|
||||
class MacroRefCondition : public MacroCondition {
|
||||
public:
|
||||
void ResolveMacroRef();
|
||||
MacroRef _macro;
|
||||
};
|
||||
|
||||
class MacroRefAction : public MacroAction {
|
||||
public:
|
||||
void ResolveMacroRef();
|
||||
MacroRef _macro;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user