diff --git a/src/advanced-scene-switcher.cpp b/src/advanced-scene-switcher.cpp index a4d50b86..1396116b 100644 --- a/src/advanced-scene-switcher.cpp +++ b/src/advanced-scene-switcher.cpp @@ -334,7 +334,7 @@ void SwitcherData::ResetForNextInterval() // Core reset functions ClearWebsocketMessages(); // Plugin reset functions - for (const auto &func : resetForNextIntervalFuncs) { + for (const auto &func : resetIntervalSteps) { func(); } } diff --git a/src/general.cpp b/src/general.cpp index f67d6323..0c57c79e 100644 --- a/src/general.cpp +++ b/src/general.cpp @@ -505,6 +505,11 @@ void SwitcherData::LoadSettings(obs_data_t *obj) loadSceneGroups(obj); LoadVariables(obj); LoadConnections(obj); + + for (const auto &func : loadSteps) { + func(obj); + } + LoadMacros(obj); loadWindowTitleSwitches(obj); loadScreenRegionSwitches(obj); @@ -559,6 +564,10 @@ void SwitcherData::SaveSettings(obs_data_t *obj) SaveHotkeys(obj); SaveUISettings(obj); SaveVersion(obj, g_GIT_SHA1); + + for (const auto &func : saveSteps) { + func(obj); + } } void SwitcherData::SaveGeneralSettings(obs_data_t *obj) diff --git a/src/macro-external/midi/midi-helpers.cpp b/src/macro-external/midi/midi-helpers.cpp index 919b065d..fbc9869e 100644 --- a/src/macro-external/midi/midi-helpers.cpp +++ b/src/macro-external/midi/midi-helpers.cpp @@ -9,7 +9,7 @@ namespace advss { static std::map, MidiDeviceInstance *> SetupMidiMessageVector() { - GetSwitcher()->AddResetForNextIntervalFunction( + GetSwitcher()->AddIntervalResetStep( MidiDeviceInstance::ClearMessageBuffersOfAllDevices); return {}; } diff --git a/src/switcher-data.cpp b/src/switcher-data.cpp index 58a6d227..2bd915df 100644 --- a/src/switcher-data.cpp +++ b/src/switcher-data.cpp @@ -168,11 +168,22 @@ void SwitcherData::SaveVersion(obs_data_t *obj, obs_data_set_string(obj, "version", currentVersion.c_str()); } -void SwitcherData::AddResetForNextIntervalFunction( - std::function function) +void SwitcherData::AddIntervalResetStep(std::function function) { std::lock_guard lock(switcher->m); - resetForNextIntervalFuncs.emplace_back(function); + resetIntervalSteps.emplace_back(function); +} + +void SwitcherData::AddSaveStep(std::function function) +{ + std::lock_guard lock(switcher->m); + saveSteps.emplace_back(function); +} + +void SwitcherData::AddLoadStep(std::function function) +{ + std::lock_guard lock(switcher->m); + loadSteps.emplace_back(function); } } // namespace advss diff --git a/src/switcher-data.hpp b/src/switcher-data.hpp index 55fd95fd..c2defd2c 100644 --- a/src/switcher-data.hpp +++ b/src/switcher-data.hpp @@ -64,7 +64,9 @@ public: void SetPreconditions(); void ResetForNextInterval(); - void AddResetForNextIntervalFunction(std::function); + void AddSaveStep(std::function); + void AddLoadStep(std::function); + void AddIntervalResetStep(std::function); bool CheckForMatch(OBSWeakSource &scene, OBSWeakSource &transition, int &linger, bool &setPreviousSceneAsMatch, bool ¯oMatch); @@ -112,7 +114,9 @@ public: std::atomic_bool abortMacroWait = {false}; std::condition_variable macroTransitionCv; - std::vector> resetForNextIntervalFuncs; + std::vector> saveSteps; + std::vector> loadSteps; + std::vector> resetIntervalSteps; bool firstBoot = true; bool transitionActive = false;