mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-08-29 12:45:28 -05:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e1020a1909 | ||
|
|
8b0bd4193b |
@@ -459,7 +459,7 @@ void SwitcherData::LoadSettings(obs_data_t *obj)
|
||||
LoadHotkeys(obj);
|
||||
LoadUISettings(obj);
|
||||
|
||||
RunPostLoadSteps();
|
||||
RunAndClearPostLoadSteps();
|
||||
|
||||
// Reset on startup and scene collection change
|
||||
ResetLastOpenedTab();
|
||||
|
||||
@@ -117,7 +117,7 @@ void MacroActionEdit::ActionSelectionChanged(const QString &text)
|
||||
*_entryData = MacroActionFactory::Create(id, macro);
|
||||
(*_entryData)->SetIndex(idx);
|
||||
(*_entryData)->PostLoad();
|
||||
RunPostLoadSteps();
|
||||
RunAndClearPostLoadSteps();
|
||||
}
|
||||
auto widget = MacroActionFactory::CreateWidget(id, this, *_entryData);
|
||||
QWidget::connect(widget, SIGNAL(HeaderInfoChanged(const QString &)),
|
||||
|
||||
@@ -239,7 +239,7 @@ void MacroConditionEdit::ConditionSelectionChanged(const QString &text)
|
||||
(*_entryData)->SetIndex(idx);
|
||||
(*_entryData)->SetLogicType(logic);
|
||||
(*_entryData)->PostLoad();
|
||||
RunPostLoadSteps();
|
||||
RunAndClearPostLoadSteps();
|
||||
}
|
||||
auto widget =
|
||||
MacroConditionFactory::CreateWidget(id, this, *_entryData);
|
||||
|
||||
@@ -1080,7 +1080,7 @@ void MacroEdit::AddMacroAction(Macro *macro, int idx, const std::string &id,
|
||||
macro->Actions().at(idx)->Load(data);
|
||||
}
|
||||
macro->Actions().at(idx)->PostLoad();
|
||||
RunPostLoadSteps();
|
||||
RunAndClearPostLoadSteps();
|
||||
macro->UpdateActionIndices();
|
||||
ui->actionsList->Insert(
|
||||
idx,
|
||||
@@ -1383,7 +1383,7 @@ void MacroEdit::AddMacroElseAction(Macro *macro, int idx, const std::string &id,
|
||||
macro->ElseActions().at(idx)->Load(data);
|
||||
}
|
||||
macro->ElseActions().at(idx)->PostLoad();
|
||||
RunPostLoadSteps();
|
||||
RunAndClearPostLoadSteps();
|
||||
macro->UpdateElseActionIndices();
|
||||
ui->elseActionsList->Insert(
|
||||
idx, new MacroActionEdit(
|
||||
@@ -1583,7 +1583,7 @@ void MacroEdit::AddMacroCondition(Macro *macro, int idx, const std::string &id,
|
||||
macro->Conditions().at(idx)->Load(data);
|
||||
}
|
||||
macro->Conditions().at(idx)->PostLoad();
|
||||
RunPostLoadSteps();
|
||||
RunAndClearPostLoadSteps();
|
||||
(*cond)->SetLogicType(logic);
|
||||
macro->UpdateConditionIndices();
|
||||
ui->conditionsList->Insert(
|
||||
|
||||
@@ -416,7 +416,7 @@ void AdvSceneSwitcher::ImportMacros()
|
||||
OBSDataAutoRelease array_obj = obs_data_array_item(array, i);
|
||||
auto macro = std::make_shared<Macro>();
|
||||
macro->Load(array_obj);
|
||||
RunPostLoadSteps();
|
||||
RunAndClearPostLoadSteps();
|
||||
|
||||
if (macroNameExists(macro->Name()) &&
|
||||
!ResolveMacroImportNameConflict(macro)) {
|
||||
@@ -444,7 +444,7 @@ void AdvSceneSwitcher::ImportMacros()
|
||||
for (const auto ¯o : importedMacros) {
|
||||
macro->PostLoad();
|
||||
}
|
||||
RunPostLoadSteps();
|
||||
RunAndClearPostLoadSteps();
|
||||
|
||||
ui->macros->Reset(GetMacros(),
|
||||
GetGlobalMacroSettings()._highlightExecuted);
|
||||
@@ -752,7 +752,7 @@ void AdvSceneSwitcher::CopyMacro()
|
||||
newMacro->Load(data);
|
||||
newMacro->PostLoad();
|
||||
newMacro->SetName(name);
|
||||
RunPostLoadSteps();
|
||||
RunAndClearPostLoadSteps();
|
||||
Macro::PrepareMoveToGroup(macro->Parent(), newMacro);
|
||||
|
||||
ui->macros->Add(newMacro, macro);
|
||||
|
||||
@@ -113,7 +113,7 @@ void ActionQueue::Add(const std::shared_ptr<MacroAction> &action)
|
||||
action->Save(data);
|
||||
copy->Load(data);
|
||||
copy->PostLoad();
|
||||
RunPostLoadSteps();
|
||||
RunAndClearPostLoadSteps();
|
||||
copy->ResolveVariablesToFixedValues();
|
||||
_actions.emplace_back(copy);
|
||||
} else {
|
||||
|
||||
@@ -113,12 +113,13 @@ void RunLoadSteps(obs_data_t *obj)
|
||||
}
|
||||
}
|
||||
|
||||
void RunPostLoadSteps()
|
||||
void RunAndClearPostLoadSteps()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(postLoadMutex);
|
||||
for (const auto &func : getPostLoadSteps()) {
|
||||
func();
|
||||
}
|
||||
getPostLoadSteps().clear();
|
||||
}
|
||||
|
||||
void ClearPostLoadSteps()
|
||||
|
||||
@@ -14,7 +14,7 @@ EXPORT void AddPostLoadStep(std::function<void()>);
|
||||
EXPORT void AddIntervalResetStep(std::function<void()>);
|
||||
void RunSaveSteps(obs_data_t *);
|
||||
void RunLoadSteps(obs_data_t *);
|
||||
EXPORT void RunPostLoadSteps();
|
||||
EXPORT void RunAndClearPostLoadSteps();
|
||||
void ClearPostLoadSteps();
|
||||
|
||||
EXPORT void AddPluginInitStep(std::function<void()>);
|
||||
|
||||
@@ -202,6 +202,8 @@ static void appendNestedMacros(std::deque<std::shared_ptr<Macro>> ¯os,
|
||||
dynamic_cast<MacroActionMacro *>(action.get());
|
||||
if (nestedMacroAction) {
|
||||
macros.push_back(nestedMacroAction->_nestedMacro);
|
||||
appendNestedMacros(
|
||||
macros, nestedMacroAction->_nestedMacro.get());
|
||||
}
|
||||
}
|
||||
for (const auto &action : macro->ElseActions()) {
|
||||
@@ -209,6 +211,8 @@ static void appendNestedMacros(std::deque<std::shared_ptr<Macro>> ¯os,
|
||||
dynamic_cast<MacroActionMacro *>(action.get());
|
||||
if (nestedMacroAction) {
|
||||
macros.push_back(nestedMacroAction->_nestedMacro);
|
||||
appendNestedMacros(
|
||||
macros, nestedMacroAction->_nestedMacro.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -301,8 +305,13 @@ void TempVariableRef::Save(obs_data_t *obj, Macro *macro,
|
||||
|
||||
void TempVariableRef::Load(obs_data_t *obj, Macro *macroPtr, const char *name)
|
||||
{
|
||||
std::deque<std::shared_ptr<Macro>> allMacros = GetMacros();
|
||||
for (const auto &topLevelMacro : GetMacros()) {
|
||||
appendNestedMacros(allMacros, topLevelMacro.get());
|
||||
}
|
||||
|
||||
std::weak_ptr<Macro> macro;
|
||||
for (const auto ¯oShared : GetMacros()) {
|
||||
for (const auto ¯oShared : allMacros) {
|
||||
if (macroShared.get() == macroPtr) {
|
||||
macro = macroShared;
|
||||
break;
|
||||
@@ -340,7 +349,7 @@ void TempVariableRef::PostLoad(int idx, SegmentType type,
|
||||
return;
|
||||
}
|
||||
|
||||
Macro *macro = nullptr;
|
||||
auto macro = childMacro.get();
|
||||
for (int i = 0; i < _depth; i++) {
|
||||
macro = getParentMacro(childMacro.get());
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ private:
|
||||
void PostLoad(int idx, SegmentType, const std::weak_ptr<Macro> &);
|
||||
|
||||
std::string _id = "";
|
||||
std::weak_ptr<MacroSegment> _segment;
|
||||
std::weak_ptr<MacroSegment> _segment = {};
|
||||
int _depth = 0;
|
||||
|
||||
friend TempVariable;
|
||||
|
||||
Reference in New Issue
Block a user