Add AddPostLoadStep()

Enables registering additional functions, which are to be executed after
the loading steps are complete
This commit is contained in:
WarmUpTill
2023-10-22 20:43:10 +02:00
committed by WarmUpTill
parent d4c7b0e455
commit c3f4caa6f3
3 changed files with 14 additions and 0 deletions

View File

@@ -499,6 +499,9 @@ void SwitcherData::LoadSettings(obs_data_t *obj)
return;
}
// New post load steps to be declared during load
postLoadSteps.clear();
// Needs to be loaded before any entries which might rely on scene group
// selections to be available.
loadSceneGroups(obj);
@@ -529,6 +532,10 @@ void SwitcherData::LoadSettings(obs_data_t *obj)
LoadHotkeys(obj);
LoadUISettings(obj);
for (const auto &func : postLoadSteps) {
func();
}
// Reset on startup and scene collection change
switcher->lastOpenedTab = -1;
startupLoadDone = true;

View File

@@ -186,4 +186,9 @@ void SwitcherData::AddLoadStep(std::function<void(obs_data_t *)> function)
loadSteps.emplace_back(function);
}
void SwitcherData::AddPostLoadStep(std::function<void()> function)
{
postLoadSteps.emplace_back(function);
}
} // namespace advss

View File

@@ -66,6 +66,7 @@ public:
void ResetForNextInterval();
void AddSaveStep(std::function<void(obs_data_t *)>);
void AddLoadStep(std::function<void(obs_data_t *)>);
void AddPostLoadStep(std::function<void()>);
void AddIntervalResetStep(std::function<void()>);
bool CheckForMatch(OBSWeakSource &scene, OBSWeakSource &transition,
int &linger, bool &setPreviousSceneAsMatch,
@@ -116,6 +117,7 @@ public:
std::vector<std::function<void(obs_data_t *)>> saveSteps;
std::vector<std::function<void(obs_data_t *)>> loadSteps;
std::vector<std::function<void()>> postLoadSteps;
std::vector<std::function<void()>> resetIntervalSteps;
bool firstBoot = true;